package com.qf.feign;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

@FeignClient(name = "sms-platform-cache2104")
public interface CacheFeign {

    @PostMapping("/cache/save2cache-persist")
    public boolean save(@RequestParam String key,@RequestParam String value);

    /**
     * 保存key-value到redis的String结构中,传入的value是Object类型
     * @param key
     * @param value
     * @return
     */
    @PostMapping("/cache/save2cache-object")
    public boolean save(@RequestParam String key, @RequestParam Object value);

    @RequestMapping(value = "/cache/get/{key}", method = RequestMethod.GET)
    public String get(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/get-object/{key}", method = RequestMethod.GET)
    public Object getObject(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/delete", method = RequestMethod.POST)
    public boolean del(@RequestParam("keys") String... keys);

    @RequestMapping(value = "/cache/hmset/{key}", method = RequestMethod.POST)
    public boolean hMSet(@PathVariable("key") String key, @RequestBody Map map);

    @RequestMapping(value = "/cache/hmget/{key}", method = RequestMethod.GET)
    public Map hMGet(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/save2cache", method = RequestMethod.POST)
    public boolean set(@RequestParam("key") String key, @RequestParam("value") String value, @RequestParam("expireSecond") Long expireSecond);

    @RequestMapping(value = "/cache/incr", method = RequestMethod.GET)
    public Long incr(@RequestParam("key") String key, @RequestParam("delta") long delta);

    @RequestMapping(value = "/cache/hget/{key}/{field}",method = RequestMethod.POST)
    public Object hget(@PathVariable(value = "key") String key,@PathVariable(value = "field") String field);

    // set结构的add操作
    @RequestMapping(value = "/cache/sadd/{key}",method = RequestMethod.POST)
    public boolean sadd(@PathVariable(value = "key")String key,@RequestParam String... set);

    // set结构的add操作
    @RequestMapping(value = "/cache/sadd-object/{key}",method = RequestMethod.POST)
    public boolean saddObject(@PathVariable(value = "key")String key,@RequestBody Set<Map> set);

    // set结构中的members,获取set中的全部数据
    @RequestMapping(value = "/cache/smembers/{key}",method = RequestMethod.GET)
    public Set<String> smembers(@PathVariable(value = "key") String key);


    // zset结构的根据分数查询数据
    @RequestMapping(value = "/cache/zrangebyscore/{key}",method = RequestMethod.GET)
    public Set<Object> zRangeByScore(@PathVariable(value = "key") String key, @RequestParam("min") Long min, @RequestParam(value = "max") Long max);


    // 对hash结构的某一个field进行incr操作
    @PostMapping("/cache/hincr")
    public Long hincr(@RequestParam(value = "key")String key,@RequestParam(value = "field")String field,@RequestParam(value = "delta")Long delta);

    //通配获取key集合
    @GetMapping(value = "/cache/keys/{key}")
    public Set<String> keys(@PathVariable(value = "key")String key);
}
